﻿using System.Collections.Generic;
using Web.Entities.Enums;

namespace Web.HelperClasses.Inflexion
{
	public class CompositeInflector : IInflector
	{
		private readonly List<IInflector> inflectors = new List<IInflector>();

		public void AddInflector(IInflector inflector)
		{
			inflectors.Add(inflector);
		}

		public string Inflect(string normalForm, Case c, bool singular)
		{
			foreach (var inflector in inflectors)
			{
				var inflectedForm = inflector.Inflect(normalForm, c, singular);
				if (!string.IsNullOrEmpty(inflectedForm))
					return inflectedForm;
			}
			
			return "";
		}
	}
}